﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="MDT_Metro_monitoring.ItemDetailPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MDT_Metro_monitoring"
    xmlns:data="using:MDT_MonitorModel"
    xmlns:common="using:MDT_Metro_monitoring.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>

        <!-- Collection d'éléments affichés par cette page -->
        <CollectionViewSource
            x:Name="itemsViewSource"
            Source="{Binding Items}"/>
        <CollectionViewSource
            x:Name="popedUpItem"
            Source="{Binding Items}"/>
        <!--d:Source="{Binding items, Source={d:DesignInstance Type=data:Computer, IsDesignTimeCreatable=True}}"-->

    </Page.Resources>

    <!--
        La grille sert de panneau racine à la page, permettant de définir deux lignes :
        * La ligne 0 qui contient le bouton Précédent et le titre de la page
        * La ligne 1 qui contient le reste de la page
    -->
    <Grid Style="{StaticResource MDTRootStyle}">

        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Popup x:Name="popUp" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.RowSpan="2" Height="200" Width="500">
            <StackPanel Background="Gray" Height="250" Width="550" >
                <StackPanel Margin="20,20,20,20">
                    <TextBlock Text="Not available yet" FontSize="30"/>

                    <TextBlock FontSize="20">
                    You can connect this computer using these information:
                    </TextBlock>

                    <TextBlock FontSize="18">
                    <LineBreak/>
                    <Run Text="{Binding popedUpItem.text1}"/> <Run Text="{Binding popedUpItem.data1}"/>
                    <LineBreak/>
                    <Run Text="{Binding popedUpItem.text2}"/> <Run Text="{Binding popedUpItem.data2}"/>
                    <LineBreak/>
                    <Run Text="{Binding popedUpItem.text3}"/> <Run Text="{Binding popedUpItem.data3}"/>
                    </TextBlock>
                    <Button Content="OK" Click="ClosePopupButton" HorizontalAlignment="Right" Margin="0,5,20,5"/>
                </StackPanel>
            </StackPanel>
        </Popup>


        <!-- Bouton Précédent et titre de la page -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Text="{Binding Title}" Style="{StaticResource PageHeaderTextStyle}" Grid.Column="1"/>
        </Grid>

        <Grid Margin="117,0,117,47" Grid.Row="1" x:Name="LandscapeView">
            <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="Column1Def" Width="560"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <RichTextBlock x:Name="Column1" Grid.Column="0" Width="560" Style="{StaticResource ItemRichTextStyle}" FontSize="18">
                <Paragraph LineStackingStrategy="MaxHeight">
                    <InlineUIContainer>
                        <Image x:Name="image" MaxHeight="480" Margin="0,20,0,10" Stretch="Uniform" Source="ms-appx:///Assets/surfaceGrand.png"/>
                    </InlineUIContainer>
                </Paragraph>
                <Paragraph>
                    <InlineUIContainer>
                        <Button x:Name="dartButton" Content="Connect with Dart" Click="DartButton_Click_1" Style="{StaticResource MDTButton}"/>
                    </InlineUIContainer>
                    <InlineUIContainer>
                        <Button x:Name="mstscButton" Content="Remote desktop" Click="MstscButton_Click_1" Style="{StaticResource MDTButton}"/>
                    </InlineUIContainer>
                    <InlineUIContainer>
                        <Button x:Name="vMConnectButton" Content="Connect to VM" Click="VmButton_Click_1" Style="{StaticResource MDTButton}"/>
                    </InlineUIContainer>
                </Paragraph>
            </RichTextBlock>
            <RichTextBlock x:Name="Column2" Grid.Column="1" Style="{StaticResource ItemRichTextStyle}" FontSize="18" Padding="0,5,0,0">
                <Paragraph Foreground="Gray" FontSize="27">
                    Deployment Status:
                    <Run FontWeight="SemiBold" Text="{Binding itemsViewSource.DeploymentStatusStr}"/>
                </Paragraph>
                <Paragraph>
                    Step Name:
                    <Run FontWeight="SemiBold" Text="{Binding itemsViewSource.StepName}"/>
                    <LineBreak/>
                    <LineBreak/>
                </Paragraph>
                <Paragraph Foreground="Gray" FontSize="27">
                    Installation completion:
                    <Run FontWeight="SemiLight" Text="{Binding itemsViewSource.PercentComplete}"/> %
                </Paragraph>
                <Paragraph>
                    Start time:
                    <Run FontWeight="SemiLight" Text="{Binding itemsViewSource.StartTime}"/>
                    <LineBreak/>
                    Last update:
                    <Run FontWeight="SemiLight" Text="{Binding itemsViewSource.LastTime}"/>
                    <LineBreak/>
                    Nb Errors:
                    <Run FontWeight="SemiLight" Text="{Binding itemsViewSource.Errors}"/>
                    <LineBreak/>
                    Nb Warnings:
                    <Run FontWeight="SemiLight" Text="{Binding itemsViewSource.Warnings}"/>
                    <LineBreak/>
                    Settings:
                    <Run FontWeight="SemiLight" Text="{Binding itemsViewSource.Settings}"/>
                </Paragraph>
            </RichTextBlock>
        </Grid>
        
        <Grid Margin="117,0,117,47" Grid.Row="1" x:Name="PortraitView">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <RichTextBlock x:Name="Row1" Grid.Row="0" Style="{StaticResource ItemRichTextStyle}" FontSize="18">
                <Paragraph LineStackingStrategy="MaxHeight">
                    <InlineUIContainer>
                        <Image x:Name="imagePortrait" MaxHeight="480" Margin="0,20,0,10" Stretch="Uniform" Source="ms-appx:///Assets/surfaceGrand.png"/>
                    </InlineUIContainer>
                </Paragraph>
                <Paragraph>
                    <InlineUIContainer>
                        <Button x:Name="dartButtonPortrait" Content="Connect with Dart" Click="DartButton_Click_1" Style="{StaticResource MDTButton}"/>
                    </InlineUIContainer>
                    <InlineUIContainer>
                        <Button x:Name="mstscButtonPortrait" Content="Remote desktop" Click="MstscButton_Click_1" Style="{StaticResource MDTButton}"/>
                    </InlineUIContainer>
                    <InlineUIContainer>
                        <Button x:Name="vMConnectButtonPortrait" Content="Connect to VM" Click="VmButton_Click_1" Style="{StaticResource MDTButton}"/>
                    </InlineUIContainer>
                </Paragraph>
            </RichTextBlock>
            <RichTextBlock x:Name="Row2" Grid.Row="1" Style="{StaticResource ItemRichTextStyle}" FontSize="18" Padding="0,5,0,0">
                <Paragraph Foreground="Gray" FontSize="27">
                    Deployment Status:
                    <Run FontWeight="SemiBold" Text="{Binding itemsViewSource.DeploymentStatusStr}"/>
                </Paragraph>
                <Paragraph>
                    Step Name:
                    <Run FontWeight="SemiBold" Text="{Binding itemsViewSource.StepName}"/>
                    <LineBreak/>
                    <LineBreak/>
                </Paragraph>
                <Paragraph Foreground="Gray" FontSize="27">
                    Installation completion:
                    <Run FontWeight="SemiLight" Text="{Binding itemsViewSource.PercentComplete}"/> %
                </Paragraph>
                <Paragraph>
                    Start time:
                    <Run FontWeight="SemiLight" Text="{Binding itemsViewSource.StartTime}"/>
                    <LineBreak/>
                    Last update:
                    <Run FontWeight="SemiLight" Text="{Binding itemsViewSource.LastTime}"/>
                    <LineBreak/>
                    Nb Errors:
                    <Run FontWeight="SemiLight" Text="{Binding itemsViewSource.Errors}"/>
                    <LineBreak/>
                    Nb Warnings:
                    <Run FontWeight="SemiLight" Text="{Binding itemsViewSource.Warnings}"/>
                    <LineBreak/>
                    Settings:
                    <Run FontWeight="SemiLight" Text="{Binding itemsViewSource.Settings}"/>
                </Paragraph>
            </RichTextBlock>
        </Grid>
        
        <VisualStateManager.VisualStateGroups>

            <!-- Les états visuels reflètent l'état d'affichage de l'application -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PortraitView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Filled"/>

                <!-- Le bouton Précédent respecte la convention de marge étroite de 100 pixels pour le mode Portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LandscapeView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- Le bouton Précédent et le titre ont un style différent lorsque l'état d'affichage a la valeur Snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Column1Def" Storyboard.TargetProperty="Width">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LandscapeView" Storyboard.TargetProperty="Margin">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="10,5,0,0"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PortraitView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
